/*
 * @(#)org.example 2020/4/7/0007
 *
 * Copy Right@ 人人译视界
 */


package org.example;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * <pre>
 * @author tuwei
 *
 * @version 0.9
 *
 * 修改版本: 0.9
 * 修改日期: 2020/4/7/0007
 * 修改人 :  tuwei
 * 修改说明: 初步完成
 * 复审人 ：
 * </pre>
 */
public class ExecutorTest {
	public static void main(String[] args) {
		Executor executor = new ThreadPoolExecutor(2, 5,
				0L, TimeUnit.MILLISECONDS,
				new ArrayBlockingQueue<>(2), new RejectedExecutionHandler() {
			@Override
			public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
				System.out.println("超过长度");
			}
		});
		for (int i = 0; i < 10; i++) {
			executor.execute(() -> {
				try {
					Thread.sleep(100000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});
		}
	}
}
